package com.gamerole.app.ui

import android.graphics.Color
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.navigation.Navigation
import com.gamerole.app.R
import com.gamerole.app.databinding.AppFragmentFirstBinding
import com.gamerole.app.viewmodel.FirstViewModel
import com.gamerole.commom.base.BaseFragment
import com.gamerole.commom.extention.click
import com.gamerole.commom.extention.color
import com.gamerole.commom.extention.nav
import com.gyf.immersionbar.ImmersionBar
import com.hi.dhl.binding.viewbind
import com.jeremyliao.liveeventbus.LiveEventBus
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collectLatest

@AndroidEntryPoint
class FirstFragment : BaseFragment(R.layout.app_fragment_first) {

    private val viewModelFirst: FirstViewModel by viewModels()
    override fun getViewModel() = viewModelFirst
    private val binding: AppFragmentFirstBinding by viewbind()

    override fun initView() {
        lifecycleScope.launchWhenCreated {
            viewModelFirst.state.collect {
                binding.first.text = it.text
            }
        }
        with(binding) {

            btBilibili.click {
                nav(R.id.chatFragment)
//                viewModelFirst.add()
            }
            btUpSearch.click {
                nav(R.id.alipanFragment)
//                viewModelFirst.add()
            }
        }
    }

    override fun initData() {

    }
}